package com.pattern.builder;

public class Context {
	private final int f1;
	private final int f2;
	private final int f3;
	private final int f4;
	private final int f5;
	private final int f6;

	private Context(InnerBuilder builder) {
		f1 = builder.f1;
		f2 = builder.f2;
		f3 = builder.f3;
		f4 = builder.f4;
		f5 = builder.f5;
		f6 = builder.f6;
	}

	private Context(OuterBuilder builder) {
		f1 = builder.getF1();
		f2 = builder.getF2();
		f3 = builder.getF3();
		f4 = builder.getF4();
		f5 = builder.getF5();
		f6 = builder.getF6();
	}

	public static Context newInstance(OuterBuilder builder) {
		return new Context(builder);
	}

	public static Context newInstance(InnerBuilder builder) {
		return new Context(builder);
	}

	@Override
	public String toString() {
		return "Context [f1=" + f1 + ", f2=" + f2 + ", f3=" + f3 + ", f4=" + f4
				+ ", f5=" + f5 + ", f6=" + f6 + "]";
	}

	public static class InnerBuilder {
		private final int f1;
		private final int f2;
		private int f3 = 0;
		private int f4 = 0;
		private int f5 = 0;
		private int f6 = 0;

		public InnerBuilder(int f1, int f2) {
			this.f1 = f1;
			this.f2 = f2;
		}

		public InnerBuilder setF3(int f) {
			this.f3 = f;
			return this;
		}

		public InnerBuilder setF4(int f) {
			this.f4 = f;
			return this;
		}

		public InnerBuilder setF5(int f) {
			this.f5 = f;
			return this;
		}

		public InnerBuilder setF6(int f) {
			this.f6 = f;
			return this;
		}
	}

}
